package com.company;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class RegisterAndLogin {

    static Map<String,String> registerMap = new HashMap<String, String>();

    public void register (){
        System.out.println("注册用户，请设置您的账号、密码\n");
        Scanner us = new Scanner(System.in);
        System.out.print("请设置您的账号:");
        String userId = us.next();

        Scanner pw = new Scanner(System.in);
        System.out.print("请设置您的密码：");
        String password = pw.next();
        System.out.println("注册成功");


        registerMap.put(userId,password);


//        System.out.println(registerMap.get(userId));
//        System.out.println(registerMap.get("user01"));

    }


    public boolean login(){
     //   System.out.println("登录");
        registerMap.put("user","user");

        String LoginID = null;
        String LoginPassword = null;
        try{
            Scanner lid = new Scanner(System.in);
            System.out.print("请输入登录账号:");
             LoginID = lid.next();
            Scanner lpw = new Scanner(System.in);
            System.out.print("请输入登录密码:");
             LoginPassword = lpw.next();

        }catch (Exception e) {
            System.out.println("错误有误,请重新输入");
        }

     //   System.out.println("密码");

        if (LoginPassword.equals(registerMap.get(LoginID))){
            System.out.println("登录成功");
            System.out.println("欢迎您~~ 用户 " + LoginID );
            return true;
        }


        System.out.println(registerMap.get(LoginID));
        System.out.println(registerMap.get("user"));

        return false;

    }


}




